// author by welong
// zuowl@qq.com
// 2014-09-05  11:15
// PAT basic 1017

#include <stdio.h>
#include <string.h>

#define LEN 1000

void str_div(char *num, int len, int divisor,char *output,  int *left)
{
	int i, j = 0; 
	int divident;

	if(len >= 2 && num[0] - '0' < divisor)
	{
		divident = (num[0]-'0')*10 + num[1]-'0';
		i = 1;
	}
	else
	{
		divident = num[0] - '0';		//strlen==1, ex 8/7 = 1 1, cause test site 1 error
		i = 0;							//have no consider num[0] >= divisor diffirent, casue test site 3,4 error
	}

	*left = divident % divisor;
	output[j++] = divident / divisor + '0';
	
	for(i; i < len-1; i++)
	{
		divident = (*left)*10 + num[i+1]-'0';
		*left = divident %divisor;
		output[j++] = divident / divisor + '0';
	}
	output[j] = 0;
}

int main(int argc, char **argv)
{
	char num[LEN], output[LEN];
	int  left, divisor;

	scanf("%s%d", num, &divisor);
	
	str_div(num, strlen(num), divisor, output, &left);
	
	printf("%s %d", output, left);

	return 0;
}